package com.ranshiyan.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ranshiyan.entity.Link;

public interface LinkMapper {
	
	//添加友情链接
	@Insert("INSERT INTO cms_link(url,NAME,created) VALUES(#{url},#{name},now())")
	int add(Link link);
	
	//修改友情链接
	@Update("UPDATE cms_link SET url=#{url},NAME=#{name} WHERE id=#{id}")
	int update(Link link);
	
	//批量删除友情链接
	int deleteBathch(@Param("ids") int[] ids);
	
	@Delete("DELETE FROM cms_link WHERE id=#{id}")
	int delete(@Param("id") int id);
	
	//查询
	@Select("SELECT id,url,NAME,created FROM cms_link ORDER BY id DESC")
	List<Link> list();
	
	@Select("SELECT id,url,NAME,created FROM cms_link WHERE id=#{value}")
	Link find(int id);
}
